package com.csd.fragment;

import com.csd.activity.CsdApplication;
import com.csd.activity.R;
import com.csd.activity.SelectCarActivity;
import com.csd.bean.Car;
import com.csd.bean.EnterpriseOrder;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class SelectCarFragment extends Fragment implements OnClickListener{

	private TextView tv_orderid,tv_purpose,tv_cartype,tv_time,tv_applaytime,tv_cartypeAfter,tv_takereturntimeAfter;
	private View v;
	private boolean isAdjust;
	private LinearLayout ll_adjust;
	private Button bt_select,bt_cancle,bt_no,bt_yes;
	private LinearLayout ll_cancel;
	@Override
	public View onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		v = inflater.inflate(R.layout.fragment_selectcar, null);
		intView();
		return v;
	}
	private void intView() {
		// TODO Auto-generated method stub
		tv_orderid = (TextView) v.findViewById(R.id.s_orderid);
		tv_purpose = (TextView) v.findViewById(R.id.s_purpose);
		tv_cartype = (TextView) v.findViewById(R.id.s_cartype);
		tv_time = (TextView) v.findViewById(R.id.s_time);
		tv_applaytime = (TextView) v.findViewById(R.id.s_applaytime);
		tv_cartypeAfter = (TextView) v.findViewById(R.id.cartype_after);
		tv_takereturntimeAfter = (TextView) v.findViewById(R.id.takereturntime_after);
		EnterpriseOrder order = new EnterpriseOrder();
		Car car = new Car();
		car.setCarBrand("别克凯越");
		order.setOrderId("1");
		order.setPurpose("接客户");
		order.setTakeTime("2014/11/06 08:30");
		order.setRetrunTime("2014/11/06 09:00");
		order.setApplyTime("2014-11-06 07:00");
		order.setCar(car);
		tv_orderid.setText("申请单：SQ-000"+order.getOrderId());
		tv_purpose.setText(order.getPurpose());
		tv_cartype.setText(order.getCar().getCarBrand());
		tv_time.setText(order.getTakeTime()+"-"+order.getRetrunTime());
		tv_applaytime.setText(order.getApplyTime());
		ll_adjust = (LinearLayout) v.findViewById(R.id.adjust);
		isAdjust = true;
		if(isAdjust){
			ll_adjust.setVisibility(View.VISIBLE);
			tv_cartypeAfter.setText("丰田威驰");
			tv_takereturntimeAfter.setText("取还车时间:"+"2014/11/06 09:30 - 2014/11/06 11:30");
		}
		bt_cancle = (Button) v.findViewById(R.id.s_cancleapplay);
		bt_select = (Button) v.findViewById(R.id.selectcar);
		bt_cancle.setOnClickListener(this);
		bt_select.setOnClickListener(this);
		ll_cancel = (LinearLayout) v.findViewById(R.id.ll_cancle);
		bt_no = (Button) v.findViewById(R.id.no);
		bt_yes = (Button) v.findViewById(R.id.yes);
		bt_no.setOnClickListener(this);
		bt_yes.setOnClickListener(this);
		
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.s_cancleapplay:
			ll_cancel.setVisibility(View.VISIBLE);
			CsdApplication.showContent(ll_cancel, getActivity());
			break;
		case R.id.selectcar:
			Intent intent = new Intent(getActivity(), SelectCarActivity.class);
			startActivity(intent);
			break;
		case R.id.yes:
			ll_cancel.setVisibility(View.VISIBLE);
			break;
		case R.id.no:
			ll_cancel.setVisibility(View.VISIBLE);
			break;
		default:
			break;
		}
	}
}
